package library;
import library.Exception.PasswordException;
import library.User.*;
import library.book.BookList;
import java.util.Scanner;

public class Main {
    public static User enroll() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的名字");
        String name = scanner.nextLine();
        System.out.println("请输入你的身份:1->管理员   0->普通用户");
        int choise = scanner.nextInt();
        if (choise == 1) {
            System.out.println("请输入管理员密码：");
            String s=scanner.nextLine();
            String password=scanner.nextLine();
            if(password.equals("12345")) {
                return new AdminUser(name);
            }else {
                throw new PasswordException("密码错误");
            }
        } else {
            return new NoramlUser(name);
        }
    }

    public static void main(String[] args) {
        User user = Main.enroll();
        BookList bookList=new BookList();
        while(true) {
            int chiose=user.menu();
            user.dowork(chiose,bookList);
        }
    }
}
